﻿///***************************************************************
/// 시  스  템 : Updms.Etc
/// 단위시스템 : ETC
/// 계      층 : Presentation Layer
/// 프로그램명 : Etc1012m
/// 파  일  명 : Etc1012m.aspx.cs
/// 설      명 : 통합게시판
///***************************************************************
/// 수정ID 일자       이름     내용
///---------------------------------------------------------------
/// CH001  2008-08-13 송시명   최초 작성
///***************************************************************
using System;
using System.Collections;
using System.Data;
using System.IO;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

using SMFramework.Data;
using SMFramework.Utility;
using SMFramework.Web.UI.WebControls.Page;

using Base.AppFramework.Web.UI.CommandBar;
using Base.Dac;

using Updms.Com.Exe;
using Updms.Etc.Exe;


namespace Updms.Etc
{
	public partial class Etc1012m : Updms.Common.BaseClass.PageBase
	{
		#region 전역영역

		//프로그램상수
		public static readonly string PID = "Etc1012m";
		public static readonly string gs_path_info = "/updms/Etc/" + PID + ".aspx";

		Global global = new Global();
		CommCode.Etc etc = new CommCode.Etc(LANG_SET);

		//페이징
		private int li_cur_page, li_row_count, li_st_page, li_ed_page;
		protected int li_page_size = 10;//GRID_PAGESIZE;// 한 페이지에 출력될 행의수

		//검색
		protected string kw1 = "";	// 구분
		protected string kw2 = "";	// 제목
        protected string kw3 = "";	// 확인

		//메뉴 선택값
		protected string gs_sm = "";

		#endregion

		#region Page_Load, OnPageLoad

		protected void Page_Load(object sender, EventArgs e)
		{
			SetInit();
			if (!Page.IsPostBack)
			{
				// 최초 화면 로딩시 처리해야 할 부분
				OnPageLoad();
				SearchProcess();
			}
		}

		// OnPageLoad
		private void OnPageLoad()
		{
			SetLiterals(global.GetLabelInfoByPgmId(PID, LANG_SET));
			SetClientScript();
			SetDiv();
			SetSearchParameter();
			SetAttachFile("0");
		}

		#endregion

		#region InitializeComponent

		private void InitializeComponent()
		{
			this.Load += new System.EventHandler(this.Page_Load);
			this.PreRender += new System.EventHandler(this.Page_PreRender);
		}

		#endregion

		#region SetClientScript
		
		private void SetClientScript()
		{
			//onKeyPress이벤트 (엔터검색)
			txt_search_title.Attributes.Add("onkeypress", "enterSearch(event)");
		}

		#endregion

		#region SetInit, SetSearchParameter, ShowKeywordLabel

		//초기값설정
		private void SetInit()
		{
			lbl_search_flag.Text = "INIT";
			if (Request.QueryString["page"] == null || int.Parse(Request.QueryString["page"]) == 1)
			{
				li_cur_page = 1;
				li_st_page = 0;
				li_ed_page = li_page_size;
			}
			else
			{
				li_cur_page = int.Parse(Request.QueryString["page"]);
				li_st_page = (int.Parse(Request.QueryString["page"]) - 1) * li_page_size;
				li_ed_page = li_st_page + li_page_size;
			}

			gs_sm = (Request.QueryString["sm"] == null || Request.QueryString["sm"].Trim().Length != 7)
					? global.GetDirDepth(PID) : Request.QueryString["sm"].ToString();
		}

		//검색파라미터
		private void SetSearchParameter()
		{
			switch (lbl_search_flag.Text.Trim().ToUpper())
			{
				case "INIT":
					if (String.IsNullOrEmpty(Request.QueryString["kw1"]))	// url에 값이 없으면
					{
						kw1 = ddl_search_div.SelectedValue;
					}
					else
					{
						kw1 = Server.UrlDecode(Request.QueryString["kw1"]);
						ddl_search_div.SelectedValue = kw1;
					}

					if (String.IsNullOrEmpty(Request.QueryString["kw2"]))	// url에 값이 없으면
					{
						kw2 = txt_search_title.Text.Trim();
					}
					else
					{
						kw2 = Server.UrlDecode(Request.QueryString["kw2"]);
						txt_search_title.Text = kw2;
					}

                    if (String.IsNullOrEmpty(Request.QueryString["kw3"]))
                    {
                        kw3 = cb_search_check_yn.Checked ? "Y" : "";
                    }
                    else
                    {
                        kw3 = Server.UrlDecode(Request.QueryString["kw3"]);
                        cb_search_check_yn.Checked = true;
                    }
					break;
				case "SEARCH":
					kw1 = ddl_search_div.SelectedValue;
					kw2 = txt_search_title.Text.Trim();
					kw3 = cb_search_check_yn.Checked ? "Y" : "";
					break;
			}
		}

		//검색키워드
		private void ShowKeywordLabel()
		{
			string ls_kw1 = ConversionUtil.CompareReplace(ddl_search_div.SelectedItem.Text, DDL_SELECT, "-");
			lbl_search_keyword.Text = ls_kw1 + " / " + kw2 + " / " + kw3;
		}

		#endregion

		#region 마스터 Method (SetDiv)

		// 공통코드에서 구분을 가져와서 ddl_search_div, ddl_div에 채운다.
		private void SetDiv()
		{
			etc.SetDiv(ddl_search_div);
			etc.SetDiv(ddl_div);

			ddl_search_div.Items.Insert(0, new ListItem(DDL_SELECT, ""));
		}
		
		#endregion

		#region 디테일 Method (SetCheckYn, SetAttachFile)

		//확인
		private void SetCheckYn(int li_seq)
		{
			DataPack lo_dp = new DataPack();
			lo_dp.AddProperty("li_seq", typeof(int), li_seq);
			lo_dp.AddProperty("ls_user_id", typeof(string), USER_ID);

			using (Etc1012m_RT _Etc1012m_RT = new Etc1012m_RT())
			{
				int li_return = _Etc1012m_RT.SetCheckYn(lo_dp);
			}
		}

		#region SetAttachFile
		//첨부파일 바인딩
		private void SetAttachFile(string activity_id)
		{
			DataSet lo_ds = new DataSet();
			DataPack lo_dp = new DataPack();

			//등록된 첨부파일수만큼 루프를돌면서 차례로 DataTable에 담고 나머지에는 파일콘트롤을 넣는다.
			DataTable lo_dt = new DataTable();

			DataColumn dc1 = new DataColumn("No", typeof(string));
			DataColumn dc2 = new DataColumn("File_Nm", typeof(string));
			DataColumn dc3 = new DataColumn("File_Size", typeof(string));
			DataColumn dc4 = new DataColumn("File_Ext", typeof(string));
			DataColumn dc5 = new DataColumn("File_Dir", typeof(string));
			DataColumn dc6 = new DataColumn("File_W_Size", typeof(string));
			DataColumn dc7 = new DataColumn("File_H_Size", typeof(string));
			DataColumn dc8 = new DataColumn("Download_Link", typeof(string));

			lo_dt.Columns.Add(dc1);
			lo_dt.Columns.Add(dc2);
			lo_dt.Columns.Add(dc3);
			lo_dt.Columns.Add(dc4);
			lo_dt.Columns.Add(dc5);
			lo_dt.Columns.Add(dc6);
			lo_dt.Columns.Add(dc7);
			lo_dt.Columns.Add(dc8);

			lo_dp.AddProperty("activity_id", typeof(int), activity_id);
			lo_dp.AddProperty("activity_cd", typeof(string), PID);

			int cnt = 0;
			//초기화할때는 DB에 가지않는다
			if (activity_id != "0")
			{
				using (Com9010m_NT _Com9010m_NT = new Com9010m_NT())
				{
					lo_ds.Merge(_Com9010m_NT.GetFileInfoByActivityId(lo_dp));
				}
				cnt = DataSetUtil.GetRowCount(lo_ds, "UPDMS_COM_FILE");
			}

			//DB에 저장된 값으로 Row를 생성
			for (int i = 0; i < cnt; i++)
			{
				DataRow dr = lo_dt.NewRow();
				dr["No"] = (i + 1).ToString();
				dr["File_Nm"] = DataSetUtil.GetFldStr(lo_ds, "UPDMS_COM_FILE", i, "File_Nm");
				dr["File_Size"] = DataSetUtil.GetFldStr(lo_ds, "UPDMS_COM_FILE", i, "File_Size");
				dr["File_Ext"] = DataSetUtil.GetFldStr(lo_ds, "UPDMS_COM_FILE", i, "File_Ext");
				dr["File_Dir"] = DataSetUtil.GetFldStr(lo_ds, "UPDMS_COM_FILE", i, "File_Dir");
				dr["File_W_Size"] = DataSetUtil.GetFldStr(lo_ds, "UPDMS_COM_FILE", i, "File_W_Size");
				dr["File_H_Size"] = DataSetUtil.GetFldStr(lo_ds, "UPDMS_COM_FILE", i, "File_H_Size");
				dr["Download_Link"] = DataSetUtil.GetFldStr(lo_ds, "UPDMS_COM_FILE", i, "Download_Link");
				lo_dt.Rows.Add(dr);
			}

			//X번 돌면서 DB에 저장된 첨부파일을 제외한것만큼 Row를 추가
			for (int j = cnt; j < FILE_UPLOAD_MULTI_MAX_COUNT; j++)
			{
				DataRow dr = lo_dt.NewRow();
				dr["No"] = (j + 1).ToString();
				dr["File_Nm"] = "";
				dr["File_Size"] = "";
				dr["File_Ext"] = "";
				dr["File_Dir"] = "";
				dr["File_W_Size"] = "";
				dr["File_H_Size"] = "";
				dr["Download_Link"] = "";
				lo_dt.Rows.Add(dr);
			}

			DataView dv = lo_dt.DefaultView;
			lo_dt = dv.ToTable();

			gv_file_list.DataSource = lo_dt;
			gv_file_list.DataBind();

			//첨부파일이 없는 row에 파일콘트롤을 추가
			for (int k = cnt; k < FILE_UPLOAD_MULTI_MAX_COUNT; k++)
			{
				if (k >= cnt)
				{
					HtmlInputFile f = new HtmlInputFile();
					f.Attributes.Add("class", "ib_file");
					gv_file_list.Rows[k].Cells[1].Controls.Add(f);
				}
			}

			//파일콘트롤에는 삭제 체크박스를 없앤다
			for (int l = 0; l < gv_file_list.Rows.Count; l++)
			{
				string ls_file_name = gv_file_list.DataKeys[l].Values["File_Nm"].ToString();
				CheckBox cb_select = (CheckBox)gv_file_list.Rows[l].FindControl("cb_select");

				if (ls_file_name == "")
				{
					cb_select.Visible = false;
				}
				else
				{
					//클릭시 취소선 설정
					cb_select.Attributes.Add("onclick", "setCancelLine('gv_file_list', " + (l + 1) + ", 2, 1);");
				}
			}
		}
		#endregion

		#endregion

		#region CRUD (SelectProcess, InsertProcess, UpdateProcess, DeleteProcess, SearchProcess)

		//조회
		private void SelectProcess()
		{
			DataSet lo_ds = new DataSet();
			DataPack lo_dp = new DataPack();
			int li_page_count;

			//검색
			lo_dp.AddProperty("ls_div", typeof(string), kw1);
			lo_dp.AddProperty("ls_title", typeof(string), kw2);
			lo_dp.AddProperty("ls_check_yn", typeof(string), kw3);
			
			using (Etc1012m_NT _Etc1012m_NT = new Etc1012m_NT())
			{
				li_row_count = _Etc1012m_NT.GetSearchCount(lo_dp);	// 검색된 행수
				li_page_count = (int)((li_row_count - 1) / li_page_size) + 1;	// 총페이지수 계산

				//모두보기/페이징
				lo_dp.AddProperty("li_st_page", typeof(Int32), (cb_list_all.Checked) ? 0 : li_st_page);
				lo_dp.AddProperty("li_ed_page", typeof(Int32), (cb_list_all.Checked) ? li_row_count : li_ed_page);
				lo_dp.AddProperty("ls_lang_set", typeof(string), LANG_SET);
				lbl_page.Visible = !cb_list_all.Checked;

				lo_ds.Merge(_Etc1012m_NT.SelectProcess(lo_dp));
			}

			GridView1.DataSource = lo_ds;
			GridView1.DataBind();

			string search_condition = "?sm=" + gs_sm + "&kw1=" + Server.UrlEncode(kw1) + "&kw2=" + Server.UrlEncode(kw2) + "&kw3=" + Server.UrlEncode(kw3) + "&page=";

			Pager pager = new Pager(this, ref lbl_page);
			pager.PageNavigation(
				li_cur_page,
				li_page_count,
				gs_path_info + search_condition);

			//결과출력(키워드, 검색행수)
			ShowKeywordLabel();
			lbl_result_count.Text = li_row_count.ToString("#,###,##0");

			//즐겨찾기
			ibtn_favorite.Attributes.Add("onclick", "javascript:goFavoriteSearchPage('" + PID + "','" + search_condition + "');return false;");
		}

		//저장
		private void InsertProcess()
		{
			using (Etc1012m_RT _Etc1012m_RT = new Etc1012m_RT())
			{
				int li_return = _Etc1012m_RT.InsertProcess(SetValue());
				string ls_msg_id = (li_return > 0) ? "MSG_INF_007" : "MSG_ERR_105";	//저장되었습니다:저장할 수 없습니다
				CallMsgBoxInAjax(ls_msg_id);
			}
			
			SearchProcess();
		}

		//수정
		private void UpdateProcess()
		{
			using (Etc1012m_RT _Etc1012m_RT = new Etc1012m_RT())
			{
				int li_return = _Etc1012m_RT.UpdateProcess(SetValue());
				string ls_msg_id = (li_return > 0) ? "MSG_INF_006" : "MSG_ERR_104";	//수정되었습니다:수정할 수 없습니다
				CallMsgBoxInAjax(ls_msg_id);

				SearchProcess();
			}
		}

		//삭제
		private void DeleteProcess(string ls_xml)
		{
			using (Etc1012m_RT _Etc1012m_RT = new Etc1012m_RT())
			{
				int li_return = _Etc1012m_RT.DeleteProcess(ls_xml);
				string ls_msg_id = (li_return > 0) ? "MSG_INF_004" : "MSG_ERR_103";	//삭제되었습니다:삭제할 수 없습니다
				CallMsgBoxInAjax(ls_msg_id);

				SearchProcess();
			}
		}

		//검색
		private void SearchProcess()
		{
			lbl_search_flag.Text = "SEARCH";
			SetSearchParameter();
			ClearValue();
			SelectProcess();
		}

		#endregion

		#region SetValue, ClearValue

		//SetValue
		private DataPack SetValue()
		{
			DataPack lo_dp = new DataPack();
			
			lo_dp.AddProperty("Seq",				typeof(string),		lbl_pk.Text);
			lo_dp.AddProperty("Div",				typeof(string), 	ddl_div.SelectedValue);
			lo_dp.AddProperty("Title",				typeof(string), 	txt_title.Text);
			lo_dp.AddProperty("Contents",			typeof(string),		editor_contents.Content);
			lo_dp.AddProperty("Check_Yn",			typeof(string),		cb_check_yn.Checked ? "Y" : "N");
			lo_dp.AddProperty("Attach_File_Info",	typeof(string),		lbl_attach_file_info.Text);
			lo_dp.AddProperty("Create_User",		typeof(string), 	USER_ID);
			lo_dp.AddProperty("Create_Dt",			typeof(string), 	"");
			lo_dp.AddProperty("Update_User",		typeof(string), 	USER_ID);
			lo_dp.AddProperty("Update_Dt",			typeof(string), 	"");

			return lo_dp;
		}

		//ClearValue
		private void ClearValue()
		{
			lbl_pk.Text = "";
			h_no.Value = "";
			ddl_div.SelectedIndex = 0;
			txt_title.Text = "";
			editor_contents.ActiveMode = AjaxControlToolkit.HTMLEditor.ActiveModeType.Design;
			editor_contents.Content = "";
			lbl_attach_file_info.Text = "<UPDMS></UPDMS>";
			SetAttachFile("0");
		}

		#endregion

		#region Page_PreRender, ChangePageMode

		// Page_PreRender
		private void Page_PreRender(object sender, System.EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				using (AccessCheck access = new AccessCheck())
				{
					//접근권한 체크
					if (!access.CheckPgmAccessGrant(PID, USER_ID, ACCESS_LOG_INFO))
					{
						Response.Redirect(URL_NO_AUTHORITY_REDIRECT_BASE);	//사용자의 권한은 요청하신 페이지를 볼 수 없습니다
					}
					//사용권한별 버튼처리
					PagePreRender.SetVisibleCtrl(this, access.CheckPgmUsingGrant(USER_DIV, PID), access.GetVisibleCtrl(PID));
				}
			}
			ChangePageMode();
		}

		//ChangePageMode
		private void ChangePageMode()
		{
			SetGridViewHeader(global.GetColumnListByPgmId(PID, LANG_SET));
		}

		#endregion

		#region File (UploadFile)

		//첨부파일업로드
		private void UploadFile()
		{
			HttpFileCollection hfc = Request.Files;
			string file_dir = PID.Substring(0, 3); //C:\UPDMS\Updms\Common\Upload\Etc
			string upload_path = FILE_PATH_UPLOAD + "\\" + file_dir;

			//DB에 저장할 파일정보를 추출한다.
			StringBuilder db_file_info = new StringBuilder();
			db_file_info.Append("<UPDMS>");

			//기존에 첨부되어있는 파일정보를 다시 생성한다.
			for (int j = 0; j < gv_file_list.Rows.Count; j++)
			{
				CheckBox cb_select = (CheckBox)gv_file_list.Rows[j].FindControl("cb_select");

				//삭제 체크 안된것만
				if (!cb_select.Checked)
				{
					string ls_file_dir = gv_file_list.DataKeys[j].Values["File_Dir"].ToString();
					string ls_file_name = gv_file_list.DataKeys[j].Values["File_Nm"].ToString();
					string ls_file_size = gv_file_list.DataKeys[j].Values["File_Size"].ToString();
					string ls_file_ext = gv_file_list.DataKeys[j].Values["File_Ext"].ToString();
					string ls_file_w_size = gv_file_list.DataKeys[j].Values["File_W_Size"].ToString();
					string ls_file_h_size = gv_file_list.DataKeys[j].Values["File_H_Size"].ToString();

					//파일업로드 콘트롤은 제외
					if (ls_file_name != "" && ls_file_size != "" && ls_file_ext != "")
					{
						db_file_info.Append("<UPDMS_COM_FILE>");
						db_file_info.Append("<File_Dir>" + ls_file_dir + "</File_Dir>");
						db_file_info.Append("<File_Nm><![CDATA[" + ls_file_name + "]]></File_Nm>");
						db_file_info.Append("<File_Size>" + ConversionUtil.ExtractNumberStr(ls_file_size) + "</File_Size>");
						db_file_info.Append("<File_Ext>" + ls_file_ext + "</File_Ext>");
						db_file_info.Append("<File_W_Size>" + ls_file_w_size + "</File_W_Size>");
						db_file_info.Append("<File_H_Size>" + ls_file_h_size + "</File_H_Size>");
						db_file_info.Append("<Create_User>" + USER_ID + "</Create_User>");
						db_file_info.Append("</UPDMS_COM_FILE>");
					}
				}
			}	//for

			//DB에 저장할 첨부파일정보
			for (int i = 0; i < hfc.Count; i++)
			{
				HttpPostedFile hpf = hfc[i];
				if (hpf.ContentLength > 0)
				{
					string ls_file_name = Path.GetFileName(hpf.FileName);	//업로드시 선택한 파일명
					string ls_file_size = (hpf.ContentLength / 1000).ToString(); //파일크기
					string ls_file_ext = Path.GetExtension(hpf.FileName).Remove(0, 1).ToUpper(); //확장자
					string ls_file_w_size = "0"; //넓이
					string ls_file_h_size = "0"; //높이
					string ls_tmp_file_name = ls_file_name; //임시파일명
					string ls_save_path = upload_path + "\\" + ls_tmp_file_name; //저장경로

					//이미지파일의 넓이와 높이를 구한다.
					if (ValidationUtil.IsFileExtImg(ls_file_ext))
					{
						System.Drawing.Image img = System.Drawing.Image.FromStream(hpf.InputStream);
						ls_file_w_size = img.Width.ToString();
						ls_file_h_size = img.Height.ToString();
					}

					//중복된 이름의 파일이 있으면 (1)을 붙인다.
					int j = 0;
					while (File.Exists(ls_save_path))
					{
						j++;
						ls_tmp_file_name = Path.GetFileNameWithoutExtension(ls_file_name) + "(" + j.ToString() + ")" + Path.GetExtension(ls_file_name);
						ls_save_path = upload_path + "\\" + ls_tmp_file_name;
					}

					db_file_info.Append("<UPDMS_COM_FILE>");
					db_file_info.Append("<File_Dir>" + file_dir + "</File_Dir>");
					db_file_info.Append("<File_Nm><![CDATA[" + ls_tmp_file_name + "]]></File_Nm>");
					db_file_info.Append("<File_Size>" + ls_file_size + "</File_Size>");
					db_file_info.Append("<File_Ext>" + ls_file_ext + "</File_Ext>");
					db_file_info.Append("<File_W_Size>" + ls_file_w_size + "</File_W_Size>");
					db_file_info.Append("<File_H_Size>" + ls_file_h_size + "</File_H_Size>");
					db_file_info.Append("<Create_User>" + USER_ID + "</Create_User>");
					db_file_info.Append("</UPDMS_COM_FILE>");

					//파일저장
					hpf.SaveAs(ls_save_path);
				}
			}	//for

			db_file_info.Append("</UPDMS>");
			lbl_attach_file_info.Text = db_file_info.ToString();
		}

		#endregion

		#region GridView이벤트

		//RowDataBound
		protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
		{
			if (e.Row.RowType == DataControlRowType.DataRow)
			{
				//마우스올렸을 때
				e.Row.Attributes.Add("onmouseover", "overBackground('GridView1', " + (e.Row.RowIndex + 1) + ")");
				e.Row.Attributes.Add("onmouseout", "outBackground('GridView1', 1)");

				//번호
				e.Row.Cells[1].Text	= cb_list_all.Checked
					? (li_row_count - e.Row.RowIndex).ToString() 
					: ((li_row_count - ((li_cur_page - 1) * li_page_size)) - e.Row.RowIndex).ToString();
			}
		}

		//RowCommand
		protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
		{
			GridView gv = (GridView)sender;
			GridViewRow row = (GridViewRow)(((Control)e.CommandSource).NamingContainer);

			LinkButton lbtn_rc = (LinkButton)GridView1.Rows[row.RowIndex].FindControl("lbtn_rc");

			//row.Cells[0].Text.ToString();//0.체크박스
			h_no.Value					= row.Cells[1].Text.ToString();										//1.번호
			lbl_pk.Text					= gv.DataKeys[row.RowIndex].Values["Seq"].ToString();				//2.Seq
			cb_check_yn.Checked			= gv.DataKeys[row.RowIndex].Values["Check_Yn"].ToString() == "Y" ? true : false;	//3.Check_Yn
																											//4.Check_Yn_Icon
			ddl_div.SelectedValue		= gv.DataKeys[row.RowIndex].Values["Div"].ToString();				//5.Div
																											//6.Div_Nm
			txt_title.Text				= lbtn_rc.Text;														//7.Title (template)
			editor_contents.Content		= gv.DataKeys[row.RowIndex].Values["Contents"].ToString();			//8.Contents
			//9.Create_Dt
			//10.Update_Dt
			//11.Create_User
			//12.Attach_File_Info

			editor_contents.ActiveMode = AjaxControlToolkit.HTMLEditor.ActiveModeType.Preview;				//미리보기모드

			SetAttachFile(lbl_pk.Text);
		}

		#endregion

		#region 버튼이벤트

		//검색
		protected void ibtn_search_Click(object sender, EventArgs e)
		{
			SearchProcess();
		}

		//저장
		protected void ibtn_save_Click(object sender, EventArgs e)
		{
			//파일업로드
			UploadFile();
			
			// CheckPK(테이블명, PK컬럼, 비교할 값)
			if (global.CheckSaveMode("UPDMS_ETC_BOARD", "Seq", lbl_pk.Text.Trim()))
			{
				// Update
				UpdateProcess();
			}
			else
			{
				// Insert
				InsertProcess();
			}
		}

		//삭제
		protected void ibtn_delete_Click(object sender, EventArgs e)
		{
			StringBuilder sb = new StringBuilder();

			sb.Append("<UPDMS>");

			for (int i = 0; i < GridView1.Rows.Count; i++)
			{
				GridViewRow row = GridView1.Rows[i];
				HtmlInputCheckBox cb = (HtmlInputCheckBox)row.FindControl("cb_check");

				if (cb.Checked)
				{
					string ls_seq = GridView1.DataKeys[i].Values["Seq"].ToString();
					sb.Append("<UPDMS_ETC_BOARD>");
					sb.Append("<Seq>" + ls_seq + "</Seq>");
					sb.Append("</UPDMS_ETC_BOARD>");
					sb.Append("<UPDMS_COM_FILE>");
					sb.Append("<Activity_Id>" + ls_seq + "</Activity_Id>");
					sb.Append("<Activity_Cd>" + PID + "</Activity_Cd>");
					sb.Append("</UPDMS_COM_FILE>");
				}
			}
			sb.Append("</UPDMS>");

			DeleteProcess(sb.ToString());
		}

		//엑셀
		protected void ibtn_excel_Click(object sender, EventArgs e)
		{
			SetSearchParameter();

			DataSet lo_ds = new DataSet();
			DataPack lo_dp = new DataPack();

			lo_dp.AddProperty("ls_div", typeof(string), kw1);
			lo_dp.AddProperty("ls_title", typeof(string), kw2);
			lo_dp.AddProperty("ls_check_yn", typeof(string), kw3);
			
			using (Etc1012m_NT _Etc1012m_NT = new Etc1012m_NT())
			{
				li_row_count = _Etc1012m_NT.GetSearchCount(lo_dp);

				lo_dp.AddProperty("li_st_page", typeof(Int32), 0);
				lo_dp.AddProperty("li_ed_page", typeof(Int32), li_row_count);
				lo_dp.AddProperty("ls_lang_set", typeof(string), LANG_SET);

				lo_ds.Merge(_Etc1012m_NT.SelectProcess(lo_dp));
			}
			string fileName = PID + "(" + global.GetMenuTitle(PID, LANG_SET) + ")";
			ExcelUtil.CreateExcelFileX(this.Page, fileName, lo_ds, SetExcelHeaderX(global.GetColumnListByPgmId(PID, LANG_SET)));
		}

		//모두보기
		protected void cb_list_all_CheckedChanged(object sender, EventArgs e)
		{
			SearchProcess();
		}

		//확인(리스트에서)
		protected void lbtn_check_yn_Click(object sender, EventArgs e)
		{
			SetCheckYn(Convert.ToInt32(h_seq.Value));
			SearchProcess();
		}

		#endregion
	}
}